<template>
  <div>
    <el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">
      <el-radio-button :label="false">展开</el-radio-button>
      <el-radio-button :label="true">收起</el-radio-button>
    </el-radio-group>
    <el-menu router class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
      <el-submenu :index="index.toString()" :key="m.id" v-for="(m,index) in userMenu">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span slot="title">{{ m.label }}</span>
        </template>
        <el-menu-item-group :key="c.id" v-for="c in m.childrenMenu">
          <el-menu-item :index="'/about'+c.path">{{ c.label }}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>

    </el-menu>

  </div>
</template>

<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>

<script>
export default {
  data() {
    return {
      isCollapse: false,
      userMenu: JSON.parse(sessionStorage.getItem('userMenu'))
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>